<?php
/*
* Robots.php
* @author Rams
*
*/
error_reporting(4);

require_once("header.php");
require_once("Robots.php");

$pageurl = trim(@$_POST['pageurl']);
$robotype = trim(@$_POST['robotype']);
$excludes = @$_POST['excludes'];

if ($robotype == 'n') {
	array_unshift($excludes, "/");
}
if (empty($excludes) ) {
	$excludes = array();
}

$robo = new Robots();

if (empty($pageurl) ) {
	echo '<table width="98%" cellpadding="1" cellspacing="1" class="">
	<form action="robotsgenerator.php" method="post" name="form12">
	  <tr>
		<td colspan="2"><p>&nbsp;</p></td>
	  </tr>
	  <tr>
		<td width="40%" class="dataLabel">Enter Your URL :</td>
		<td width="60%" class="dataField"><input size="40" value="" name="pageurl" class="input"></td>
	  </tr>
	  <tr>
		<td class="dataLabel">Which Robots to allow :</td>
		<td class="dataField"><input type="radio" value="y" name="robotype" checked="checked">
		  All Robots
		  <input type="radio" value="n" name="robotype">
		No Robots (Use All if not sure) </td>
	  </tr>
	  <tr>
		<td class="dataLabel">Exclude this directory/file   :</td>
		<td class="dataField"><input value="" name="excludes[]" class="input" size="25">
		(e.g. /cgi-bin/ or /contact.php)</td>
	  </tr>
	  <tr>
		<td class="dataLabel">Exclude this directory/file   :</td>
		<td class="dataField"><input name="excludes[]" class="input" size="25"></td>
	  </tr>
	  <tr>
		<td class="dataLabel">Exclude this directory/file   :</td>
		<td class="dataField"><input name="excludes[]" class="input" size="25"></td>
	  </tr>
	  <tr>
		<td colspan="2"><p>&nbsp;</p></td>
	  </tr>
	  <tr>
		<td colspan="2" class="dataField"><div align="center">
		  <input type="submit" value="Create Robots.txt file" name="Submit" class="button">
		</div></td>
	  </tr>
	 </form>
	</table>';
} else {
	echo '<table width="98%" border="0" cellspacing="0" cellpadding="0">
	  <tr>
		<td>&nbsp;</td>
	  </tr>
	  <tr>
		<td align="center"><table width="90%" cellpadding="0" cellspacing="0">
		  <tr>
			<td width="99%">&nbsp;</td>
			<td valign="top" width="1%" rowspan="2"></td>
		  </tr>
		  <tr>
			<td valign="top" align="center" class="bodytext"><br />
					  <textarea name="textarea" cols="90" rows="12" class="input">'.$robo->generate($pageurl,$excludes).'</textarea>
					  <br /><br />
					  Copy and paste the text above and save to a file called <strong>robots.txt</strong>. 
					  Then place this file in the same directory as your   home page.</div>
			</td>
		  </tr>
		</table></td>
	  </tr>
	  <tr>
		<td>&nbsp;</td>
	  </tr>
	</table>';
}

require_once("footer.php");
?>